home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / TreeUI.java < prev    next >
Text File  |  1998-06-30  |  6KB  |  182 lines

  1. /*
  2.  * @(#)TreeUI.java    1.15 97/09/30
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.plaf;
  22.  
  23. import java.awt.Rectangle;
  24. import com.sun.java.swing.tree.TreePath;
  25.  
  26. /**
  27.  * Pluggable look and feel interface for JTree.
  28.  *
  29.  * @version 1.15 09/30/97
  30.  * @author Rob Davis
  31.  * @author Scott Violet
  32.  */
  33. public abstract class TreeUI extends ComponentUI
  34. {
  35.     /**
  36.       * Returns the number of rows that are being displayed.
  37.       */
  38.     public abstract int getRowCount();
  39.  
  40.     /**
  41.       * Returns true if the value identified by path is currently expanded,
  42.       * this will return false if any of the values in path are currently
  43.       * not being displayed.
  44.       */
  45.     public abstract boolean isExpanded(TreePath path);
  46.  
  47.     /**
  48.       * Returns true if the value identified by row is currently expanded.
  49.       */
  50.     public abstract boolean isExpanded(int row);
  51.  
  52.     /**
  53.       * Returns true if the value identified by path is currently collapsed,
  54.       * this will return false if any of the values in path are currently
  55.       * not being displayed.
  56.       */
  57.     public abstract boolean isCollapsed(TreePath path);
  58.  
  59.     /**
  60.       * Returns true if the value identified by row is currently collapsed.
  61.       */
  62.     public abstract boolean isCollapsed(int row);
  63.  
  64.     /**
  65.       * Ensures that all of the parents of path are currently expanded.
  66.       * To make sure it is truyly visible, you may wish to call
  67.       * scrollPathToVisible, which will try and scroll the path to be
  68.       * visibile if the JTree is in a scroller.
  69.       */
  70.     public abstract void makeVisible(TreePath path);
  71.  
  72.     /**
  73.       * Returns true if all the parents of path are currently expanded.
  74.       */
  75.     public abstract boolean isVisible(TreePath path);
  76.  
  77.     /**
  78.       * Returns the Rectangle enclosing the label portion that the
  79.       * last item in path will be drawn into.  Will return null if
  80.       * any component in path is currently valid.
  81.       */
  82.     public abstract Rectangle getPathBounds(TreePath path);
  83.  
  84.     /**
  85.       * Returns the Rectangle enclosing the label portion that the
  86.       * item identified by row will be drawn into.
  87.       */
  88.     public abstract Rectangle getRowBounds(int row);
  89.  
  90.     /**
  91.       * Makes sure all the path components in path are expanded (accept
  92.       * for the last path component) and tries to scroll the resulting path
  93.       * to be visible (the scrolling will only work if the JTree is
  94.       * contained in a JScrollPane).
  95.       */
  96.     public abstract void scrollPathToVisible(TreePath path);
  97.  
  98.     /**
  99.       * Scrolls the item identified by row to be visible.  This will
  100.       * only work if the JTree is contained in a JSrollPane.
  101.       */
  102.     public abstract void scrollRowToVisible(int row);
  103.  
  104.     /**
  105.       * Returns the path for passed in row.  If row is not visible
  106.       * null is returned.
  107.       */
  108.     public abstract TreePath getPathForRow(int row);
  109.  
  110.     /**
  111.       * Returns the row that the last item identified in path is visible
  112.       * at.  Will return -1 if any of the elements in path are not
  113.       * currently visible.
  114.       */
  115.     public abstract int getRowForPath(TreePath path);
  116.  
  117.     /**
  118.       * Insures that the last item identified in path is expanded and
  119.       * visible.  This differs from makeVisible in that the last item
  120.       * is expanded in this method.
  121.       */
  122.     public abstract void expandPath(TreePath path);
  123.  
  124.     /**
  125.       * Insures that the item identified by row is expanded.
  126.       */
  127.     public abstract void expandRow(int row);
  128.  
  129.     /**
  130.       * Insures that the last item identified in path is collapsed and
  131.       * visible.
  132.       */
  133.     public abstract void collapsePath(TreePath path);
  134.  
  135.     /**
  136.       * Insures that the item identified by row is collapsed.
  137.       */
  138.     public abstract void collapseRow(int row);
  139.  
  140.     /**
  141.       * Returns the path to the node that is closest to x,y.  If
  142.       * there is nothing currently visible this will return null, otherwise
  143.       * it'll always return a valid path.  If you need to test if the
  144.       * returned object is exactly at x, y you should get the bounds for
  145.       * the returned path and test x, y against that.
  146.       */
  147.     public abstract TreePath getClosestPathForLocation(int x, int y);
  148.  
  149.     /**
  150.       * Returns the row to the node that is closest to x,y.  If
  151.       * there is nothing currently visible this will return -1, otherwise
  152.       * it'll always return a valid row.  If you need to test if the
  153.       * returned object is exactly at x, y you should get the bounds for
  154.       * the returned row and test x, y against that.
  155.       */
  156.     public abstract int getClosestRowForLocation(int x, int y);
  157.  
  158.     /**
  159.       * Returns true if the tree is being edited.  The item that is being
  160.       * edited can be returned by getEditingPath().
  161.       */
  162.     public abstract boolean isEditing();
  163.  
  164.     /**
  165.       * Stops the current editing session.  This has no effect if the
  166.       * tree isn't being edited.  Returns true if the editor allows the
  167.       * editing session to stop.
  168.       */
  169.     public abstract boolean stopEditing();
  170.  
  171.     /**
  172.       * Selects the last item in path and tries to edit it.  Editing will
  173.       * fail if the CellEditor won't allow it for the selected item.
  174.       */
  175.     public abstract void startEditingAtPath(TreePath path);
  176.  
  177.     /**
  178.      * Returns the path to the element that is being edited.
  179.      */
  180.     public abstract TreePath getEditingPath();
  181. }
  182.